import React, { Component } from 'react'
// 受控组件 value、checked / onChange

class App extends Component {
  state = {
    sex: 1,
    city: '2000'
  }
  setSex = (value) => () => {
    this.setState({ sex: value })
  }

  render() {
    return (
      <div>
        <div>
          <label>
            <input
              type="radio"
              value={1}
              checked={this.state.sex == 1}
              onChange={this.setSex(1)}
            />
            先生
          </label>
          <label>
            <input
              type="radio"
              value={2}
              checked={this.state.sex == 2}
              onChange={this.setSex(2)}
            />
            女士
          </label>
        </div>
        <div>
          <select
            value={this.state.city}
            onChange={(e) => this.setState({ city: e.target.value })}
          >
            <option value="1000">北京</option>
            <option value="2000">上海</option>
            <option value="3000">南京</option>
          </select>
        </div>
      </div>
    )
  }
}

export default App
